import Vue from 'vue'
import Router from 'vue-router'
import HomePage from '@/iviews/HomePage'
import GoodsData from '@/iviews/GoodsData'
import JoinDraw from '@/iviews/JoinDraw'
import MyDraw from '@/iviews/MyDraw'
import HavePrize from '@/iviews/HavePrize'
import LuckyCode from '@/iviews/LuckyCode'
import PrizeDetail from '@/iviews/PrizeDetail'
import JoinSuccess from '@/iviews/JoinSuccess'
import FillAddress from '@/iviews/FillAddress'
import GetGoods from '@/iviews/GetGoods'
import UsageMethod from '@/iviews/UsageMethod'
import OrderDetails from '@/iviews/OrderDetails'

Vue.use(Router)

const router=  new Router({

  mode:'history',


  routes: [
    {
      path: '/',
      name: 'HomePage',
      component: HomePage
    },
    {
      path: '/GoodsData',
      name: 'GoodsData',
      component: GoodsData
    },
    {
      path: '/JoinDraw',
      name: 'JoinDraw',
      component: JoinDraw
    },
    {
      path: '/MyDraw',
      name: 'MyDraw',
      component: MyDraw
    },
    {
      path: '/HavePrize',
      name: 'HavePrize',
      component: HavePrize
    },
    {
      path: '/LuckyCode',
      name: 'LuckyCode',
      component: LuckyCode
    },
    {
      path: '/PrizeDetail',
      name: 'PrizeDetail',
      component: PrizeDetail
    },
    {
      path: '/JoinSuccess',
      name: 'JoinSuccess',
      component: JoinSuccess
    },
    {
      path: '/FillAddress',
      name: 'FillAddress',
      component: FillAddress
    },
    {
      path: '/GetGoods',
      name: 'GetGoods',
      component: GetGoods
    },
    {
      path: '/UsageMethod',
      name: 'UsageMethod',
      component: UsageMethod
    },
    {
      path: '/OrderDetails',
      name: 'OrderDetails',
      component: OrderDetails
    },
  ]
})


router.beforeEach((to, from, next) => {
  
  const setTitle = (name) => {
    switch (name) {
      case 'GoodsData':
        document.title = '详情'
        break;
      case 'JoinDraw':
        document.title = '参与抽奖确认'
        break;
      case 'MyDraw':
        document.title = '我的抽奖'
        break;
      case 'HavePrize':
        document.title = '已开奖列表'                              
  
        break;
      case 'LuckyCode':
        document.title = '幸运码'
        break;
      case 'PrizeDetail':
        document.title = '邀请码'
        break;
      case 'JoinSuccess':
        document.title = '参与成功'
        break;
      case 'FillAddress':
        document.title = '填写收货地址'
        break;
      case 'GetGoods':
        document.title = '领取奖励'
        break;
      case 'UsageMethod':
        document.title = '领取奖励'
        break;
      case 'OrderDetails':
        document.title = '填写收货地址'
        break;
      case 'HomePage':
        document.title = '金币抽奖'
        break;
      default:
        document.title = '小印象'
        break;
    }
  }
   
      setTitle(to.name)
 
      next()
 });









export default router